# from os import PRIO_USER
import requests


class Base:
    def __init__(self, root):
        self.rootPath = root

    def base_method(self, method, url):
        """基础方法

        Args:
            method (strings): 请求方法
            url (strings): 请求地址
        """
        print(url)
        payload={}
        headers = {
            'User-Agent': 'vscode-client'
        }
        response = requests.request(method, self.rootPath + url, headers=headers, data=payload)
        print(response.status_code)
        print(response.text)
        return

    def base_get(self, url):
        self.base_method('GET', url)

    def base_post(self, url):
        self.base_method('POST', url)

    @staticmethod
    def generate_params(names, values):
        """生成请求参数

        Args:
            names (list): list of name
            values (list): list of value

        Returns:
            string: 参数字符串
        """
        kvDict = dict(zip(names, values))
        kvLst = map(lambda x, y: '='.join([x, y]), kvDict.keys(), kvDict.values())
        return '&'.join(kvLst)